﻿
using Xacml.Core.Interfaces;
using Xacml.Core.Runtime;
using System;

namespace Xacml.Core.Runtime.Functions
{
  public class IntegerAbs : FunctionBase
  {
    public override string Id
    {
      get
      {
        return "urn:oasis:names:tc:xacml:1.0:function:integer-abs";
      }
    }

    public override IDataType Returns
    {
      get
      {
        return (IDataType) DataTypeDescriptor.Double;
      }
    }

    public override IDataType[] Arguments
    {
      get
      {
        return new IDataType[1]
        {
          (IDataType) DataTypeDescriptor.Double
        };
      }
    }

    public override EvaluationValue Evaluate(EvaluationContext context, params IFunctionParameter[] args)
    {
      return new EvaluationValue((object) Math.Abs(this.GetIntegerArgument(args, 0)), (IDataType) DataTypeDescriptor.Integer);
    }
  }
}
